package s05;

import java.util.Arrays;

/**
 * @ClassName ComparatorLambdaDemo
 * @Description TODO
 * @Author Li
 * @Date 2022/8/9 16:23
 * @ModifyDate 2022/8/9 16:23
 * @Version 1.0
 */
public class ComparatorLambdaDemo {
    public static void main(String[] args) {
        // 初始化年龄乱序的对象数组
        Person[] array = {
                new Person("张三", 25),
                new Person("李四", 22),
                new Person("王二", 28)
        };
        // Lambda写法
        Arrays.sort(array,(Person o1, Person o2)->{return o1.getAge() - o2.getAge();});

        for (Person person : array) {
            System.out.println(person);
        }
    }
}
